package Base;

import global.Const;

import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class Dialog extends JPanel {
    public JPanel window = new JPanel(); // 弹窗
    public JPanel panel =new JPanel();                 // 背景

    public void initWindow() {
        // 设置窗口
        setBounds(0, 0, Const.PANEL_WIDTH, Const.PANEL_HEIGHT);
        setBackground(new Color(0, 0, 0, 0));
        setVisible(false);
        setLayout(null);

        // 设置背景
        panel.setBackground(new Color(0, 0, 0, 100));  // 半透明背景
        panel.setBounds(0, 0, getWidth(),getHeight());

        // 弹窗窗口
        window.setBounds(70, 380, Const.WINDOW_WIDTH, Const.WINDOW_HEIGHT);
        window.setLayout(null);
        window.setBackground(Color.white);

        // 添加组件
        add(window);
        add(panel);

        // 防止点到下层容器的组件
        addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                e.consume();
            }
        });
    }

}
